/* 
 *  Copyright (c) 2011—2013 Panguso.com. All rights reserved. 
 *  File Name:  CleanConfigSave.java                                      
 *  File Contents Outline :  保存清晰过滤规则                  
 *  File  Create Date:   2012年7月30日
 *  File Version#: Revision#: #1                  
 *  File  Latest Modify Date : 2013年1月16日
 *  File Author :  bachuan@panguso.com
 */

/*
 
* To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.edu.thu.log.tree;

/**
 * 多叉树
 *
 * @author wan
 */
public class ManyTree {

    private ManyTreeNode root=null;

    public ManyTree(ManyTreeNode root){
        this.root=root;
    }
    
    //中序遍历多叉树  
    public String iteratorTree(ManyTreeNode treeNode) {

        StringBuilder sb = new StringBuilder();
        if (treeNode != null) {
            if ("1".equals(treeNode.getData().getKey())) {               
                sb.append(treeNode.getData().getKey() + ",");
            }

            for (ManyTreeNode index : treeNode.getChildList()) {
                sb.append(index.getData().getKey() + ",");
                if (index.getChildList() != null && index.getChildList().size() > 0) {
                    sb.append(iteratorTree(index));
                }
            }
        }
        return sb.toString();
    }

    /**
     * @return the root
     */
    public ManyTreeNode getRoot() {
        return root;
    }

    /**
     * @param root the root to set
     */
    public void setRoot(ManyTreeNode root) {
        this.root = root;
    }
    
    
}
